﻿using System.Collections.Generic;

namespace Nemerle.Xml
{
  using Node;
  using DocumentElement;
  using Namespace;

  /// <summary>
  /// Represents Xml Namespace. See Context for details
  /// </summary>
  public variant Namespace : System.IEquatable[Namespace]
  {
    | Uri      { value : string; }
    | UriAlias { value : string; }
    | Empty

    public override GetHashCode() : int
    {
      match (this)
      {
        | Uri(value)      => value.GetHashCode()
        | UriAlias(value) => value.GetHashCode()
        | _               => 1042
      }
    }

    public override Equals(obj : object) : bool
    {
      if (object.ReferenceEquals(this, obj))
        true
      else
        match (this, obj)
        {
          | (Uri(left),      Uri(right))      => left == right
          | (UriAlias(left), UriAlias(right)) => left == right
          | (Empty,          Empty)           => true
          | _                                 => false
        }
    }

    public Equals(ns : Namespace) : bool implements System.IEquatable[Namespace].Equals
    {
      Equals(ns : object)
    }
  }
}
